home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / SHOWINFO.C < prev    next >
Text File  |  1992-05-14  |  3KB  |  77 lines

  1. /************************************************************************************/
  2. /*    ShowInfoDlog                                                                    */
  3. /*      This proc dislpays a dialog with only simple text and an OK button (item #1),    */
  4. /*    an optional Cancel button (item #2), and a userItem surrounding the OK button    */
  5. /*    (item #3), an optional icon (item #4) and optional version info (item #5).        */
  6. /*                                                                                    */
  7. /*    Note.  Item number of userItems are hardcoded.                                    */
  8. /************************************************************************************/
  9.  
  10. #include "MyHeaders.h"
  11.  
  12. int ShowInfoDlog(int dlogNo)
  13. {
  14.     int            SIRetCode = 0;
  15.     
  16.     Rect        dlogRect;
  17.     int            rectHeight, rectWidth;
  18.     int            newH, newV;
  19.     int            itemHit;                                /* return from modal dialog    */
  20.     
  21.     
  22.     myDlogPtr = GetNewDialog (dlogNo, NIL, (WindowPtr) -1);        /* get the dialog    */
  23.  
  24.     dlogRect = (*myDlogPtr).portRect;                    /* position dlog on desktop    */
  25.     rectHeight = dlogRect.bottom - dlogRect.top;        
  26.     rectWidth = dlogRect.right - dlogRect.left;
  27.     newH = (screenBits.bounds.right - rectWidth) * .50;    /* centered    horizonally        */
  28.     if (newH < 10)                                        /* (not less than 10)        */
  29.         newH = 10;
  30.     newV = ((screenBits.bounds.bottom - 30                /* vertical position        */
  31.              - rectHeight)* (.33)) + 30;                /*   one-third down            */
  32.     if (newV < 30)                                        /* (not less than 30)        */
  33.         newV = 30;
  34.     MoveWindow (myDlogPtr, newH, newV, TRUE);            /* move to new position        */
  35.     
  36.     GetDItem (myDlogPtr, 3, &workInt,                    /* get info about useritem    */
  37.         &workHandle, &workRect);                        /*  (must be item #3)        */
  38.     SetDItem (myDlogPtr, 3, userItem,                    /* insert draw proc pointer    */
  39.         (Handle) DrawDefaultBorder, &workRect);            /* into info about useritem    */
  40.         
  41.                                                         /* if there is an icon, it    */
  42.                                                         /* will be a disabled user    */
  43.                                                         /* item whose item # is 4    */
  44.     GetDItem (myDlogPtr, 4, &workInt,                    /* get info about useritem    */
  45.         &workHandle, &workRect);                        /*  (must be item #4)        */
  46.     if (workInt == userItem + itemDisable)                /* if a disabled useritem    */
  47.         SetDItem (myDlogPtr, 4, userItem,                /* put icon draw proc ptr    */
  48.             (Handle) DrawUserIcon, &workRect);            /* into info about useritem    */
  49.  
  50.     SetPort (myDlogPtr);
  51.     TextFont(geneva);
  52.     TextFace(NIL);
  53.     TextSize(10);
  54.  
  55.     ParamText (versLongStr,"","","");                    /* Set substitution string    */
  56.  
  57.     CursorSelect (NIL, NIL, NIL);                        /* get arrow csr for dialog    */
  58.     ShowWindow (myDlogPtr);                                /* make visible                */
  59.     
  60.     itemHit = 0;                                        /* initialize before loop    */
  61.     while ((itemHit != ok) && (itemHit != cancel))        /* loop till ok or cancel    */
  62.         ModalDialog(NIL, &itemHit);                        /*   stick here until a hit    */
  63.  
  64.     if (dlogNo == 130)                                    /* if it is the Kudos dlog    */
  65.         {                                                /*   perform applause        */
  66.         theSnd = GetResource ('snd ', 9001);            /*   before disposing of    */
  67.         theSndChan = NIL;                                /*   the dialog.            */
  68.         sndRC = SndPlay (theSndChan, theSnd, TRUE);
  69.         ReleaseResource (theSnd);
  70.         }
  71.         
  72.     DisposDialog(myDlogPtr);                            /* release storage, etc.    */
  73.  
  74.     SIRetCode = itemHit;                                /* return: 1=ok, 2=cancel    */
  75.     return SIRetCode;
  76. }
  77.